package per.jdz.demo.utils;

/**
 * @author Jdz
 * @date 2025/1/10
 */
public class GeoUtil {
    public static double[] BdMapToTxMap(String lat1, String lon1) {

        double lat = Double.parseDouble(lat1);

        double lon = Double.parseDouble(lon1);

        double tx_lat;

        double tx_lon;

        double x_pi = (3.14159265358979324 * 3000.0) / 180.0;

        double x = lon - 0.0065;

        double y = lat - 0.006;

        double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);

        double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);

        tx_lon = z * Math.cos(theta);

        tx_lat = z * Math.sin(theta);

//        System.out.println("tx_lat:" + tx_lat);

//        System.out.println("tx_lon:" + tx_lon);

        return new double[]{tx_lat, tx_lon};

    }
}
